<template>
  <div class="children">
    <el-divider>基本信息</el-divider>
    <div class="dialog_left">
      <el-descriptions direction="vertical" :column="4" border>
        <el-descriptions-item label="任务单编号">{{ form.upkeepTaskNum || '-' }}</el-descriptions-item>
        <el-descriptions-item label="申请单号">{{
          form.ukPlanPartInfoVo && form.ukPlanPartInfoVo && form.ukPlanPartInfoVo &&
            form.ukPlanPartInfoVo.upkeepPlanNum || '-'
        }}</el-descriptions-item>
        <el-descriptions-item label="标题">{{ form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.title || '-' }}
        </el-descriptions-item>
        <el-descriptions-item label="设备编号">{{ form.equipmentNum || '-' }}</el-descriptions-item>
        <el-descriptions-item label="设备名称">{{ form.equipmentName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="供应商">{{ form.supplierName || '-' }}</el-descriptions-item>
        <el-descriptions-item label="保养人">
          <span v-for="(v, i) in form.upkeepPlanMaintainerList" :key="i">
            {{ v.maintainerName || '-' }}
            <template v-if="i !== form.upkeepPlanMaintainerList.length - 1">
              ,
            </template>
          </span>
          <!-- {{ form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.headName || '-' }} -->
        </el-descriptions-item>
        <el-descriptions-item label="保养部门">{{ form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.deptName || '-' }}
        </el-descriptions-item>
        <el-descriptions-item label="循环类型">{{
          ['循环保养', '单次保养'][form.ukPlanPartInfoVo && form.ukPlanPartInfoVo &&
            form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.generateTaskType] || '-'
        }}</el-descriptions-item>
        <el-descriptions-item label="生成任务">{{
          ['提前一日', '提前二日', '提前三日',
            '提前四日', '提前五日'][form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.generateTaskType]
            || '-'
        }}
        </el-descriptions-item>

        <el-descriptions-item label="验收人">{{ form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.acceptorName || '-' }}
        </el-descriptions-item>
        <el-descriptions-item label="验收人部门">{{
          form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.acceptanceDeptName || '-'
        }}</el-descriptions-item>
        <el-descriptions-item label="验收方式">{{
          form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.acceptanceModeName || '-'
        }}</el-descriptions-item>

        <el-descriptions-item label="计划保养日期">{{ form.planUpkeepTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="生成日期">{{ form.generateTime || '-' }}</el-descriptions-item>
        <el-descriptions-item label="备注">{{ form.ukPlanPartInfoVo && form.ukPlanPartInfoVo.remark || '-' }}
        </el-descriptions-item>
      </el-descriptions>
      <el-descriptions :column="1" border>
        <el-descriptions-item label-class-name="left_herder" label="保养状态">
          <span v-for="(value, index) in form.upkeepTaskStatuses" :key="index">
            <dict-tag :options="upkeepStatus" :value="value.upkeepStatus" />
            ({{ value.acceptanceTime || '-' }})
            <span :style="{ 'margin': '0 5px' }" v-if="index !== form.upkeepTaskStatuses.length - 1">/</span>
          </span>
        </el-descriptions-item>
        <el-descriptions-item label="验收状态">
          <span v-for="(value, index) in form.upkeepTaskStatuses" :key="index">
            <dict-tag :options="acceptanceStatus" :value="value.acceptanceStatus" />
            ({{ value.acceptanceTime || '-' }})
            <span :style="{ 'margin': '0 5px' }" v-if="index !== form.upkeepTaskStatuses.length - 1">/</span>
          </span>
        </el-descriptions-item>

        <el-descriptions-item label="验收说明">
          <span v-for="(value, index) in form.upkeepTaskStatuses" :key="index">
            {{ value.explanation }} <span :style="{ 'margin': '0 5px' }"
              v-if="index !== form.upkeepTaskStatuses.length - 1">/</span>
          </span>

        </el-descriptions-item>
      </el-descriptions>
    </div>
    <el-divider>保养标准</el-divider>
    <div v-for="(item, index) in form.upkeepTaskStatuses" :key="index">
      <el-table :data="item.upkeepTaskGenerProVos">
        <el-table-column label="序号" align="center" width="50">
          <template slot-scope="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column label="编号" align="center" width="160">
          <template slot-scope="scope">
            {{ scope.row.upkeepType && scope.row.upkeepType.typeNum || '-' }}
          </template>
        </el-table-column>
        <el-table-column label="名称" align="center" min-width="120">
          <template slot-scope="scope">
            {{ scope.row.upkeepType.typeName || '-' }}
          </template>
        </el-table-column>
        <!-- <el-table-column label="周期" align="center" min-width="120">
          <template slot-scope="scope">
            {{ ['一日', '一周', '十五日', '一月', '三月', '六月', '十二月', '不定'][scope.row.upkeepType && scope.row.upkeepType.cycle] ||
                '-'
            }}
          </template>
        </el-table-column>
        <el-table-column label="排序" align="center" min-width="120">
          <template slot-scope="scope">
            {{ scope.row.upkeepType && scope.row.upkeepType.sort || '-' }}
          </template>
        </el-table-column> -->
        <!-- <el-table-column label="状态" align="center" min-width="120">
                    <template slot-scope="scope">
                      <dict-tag :options="statusFlag" :value="scope.row.status" />
                    </template>
                  </el-table-column> -->
        <el-table-column label="备注" align="center" min-width="180">
          <template slot-scope="scope">
            {{ scope.row.upkeepType && scope.row.upkeepType.remark || '-' }}
          </template>
        </el-table-column>
        <el-table-column label="保养状态" align="center" width="100">
          <template slot-scope="scope">
            <el-switch v-model="scope.row.status" active-color="#13ce66" inactive-color="#909399" active-value="1"
              inactive-value="0" disabled>
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column label="保养说明" align="center" min-width="380" show-overflow-tooltip>
          <template slot-scope="scope">
            <!-- <template v-if="scope.row.status === '1'">
                          <el-input v-model="scope.row.explanation"></el-input>
                        </template> -->
            <!-- <template v-else> -->
            {{ scope.row.explanation || '-' }}
            <!-- </template> -->
          </template>
        </el-table-column>
      </el-table>
      <el-divider v-if="index !== form.upkeepTaskStatuses.length - 1">保养标准(重新保养)</el-divider>
    </div>
    <el-divider>配件更换</el-divider>
    <el-table v-if="form.ecrRemoveRecords.length !== 0" :data="form.ecrRemoveRecords" border>
      <el-table-column label="物料名称" prop="materialName">
      </el-table-column>
      <el-table-column label="数量" prop="amount">
      </el-table-column>
    </el-table>
    <el-empty v-else description="无配件更换" :image-size="35"></el-empty>
  </div>
</template>

<script>
import { getSelectChildrenupkeep } from "@/api/maintenance/insurance/insurance.js";
// import Upload from '@/components/upload/index.vue'
export default {
  props: ['rowObj'],
  components: {
    // Upload
  },
  data () {
    return {
      form: {
      },

    }
  },
  created () {
    this.getlist()
  },
  methods: {
    async getlist () {
      let res = await getSelectChildrenupkeep(this.rowObj.upkeepTaskId, this.rowObj.equipmentAccountId);//保养任务ID/设备台账ID
      this.form = res.data
    },

  }
}
</script>

<style lang="scss" scoped>
.center_dialog {
  // text-align: center;
  width: 90%;
  margin: 0px auto;
}
</style>